package com.lovo.sys.controller;

import com.alibaba.fastjson.JSONObject;
import com.lovo.commom.dto.ProductInfoDto;
import com.lovo.sys.bean.ProductBean;
import com.lovo.sys.bean.ProductInfoBean;
import com.lovo.sys.mapper.IProductInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("productInfo")
public class ProductInfoController {
    @Autowired
    private IProductInfoMapper infoMapper;

    /**
     * 远程调用修改明细售价方法
     *
     * @param obj
     */
    @GetMapping("updateProductInfoPrice/{obj}")
    public boolean updateProductInfoPrice(@PathVariable("obj") String obj) {
        ProductBean productBean = JSONObject.parseObject(obj, ProductBean.class);
        for (ProductInfoBean pi : productBean.getProductInfoList()) {
            infoMapper.updateById(pi);
        }
        return true;
    }


}
